package com.gb.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.DelegatingFilterProxy;

/**
 * 过滤器配置
 *
 * @author liaosh
 * @version 1.0.0
 * @Date 2017/8/15 20:06
 */
@Configuration
public class FilterConfig {

    protected Logger log = LoggerFactory.getLogger(FilterConfig.class);

    @Bean
    public FilterRegistrationBean shiroFilterRegistration() {
        log.info("=====FilterConfig.shiroFilterRegistration=====");
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new DelegatingFilterProxy("shiroFilter"));
        //该值缺省为false，表示生命周期由SpringApplicationContext管理，设置为true则表示由ServletContainer管理
        registration.addInitParameter("targetFilterLifecycle", "true");
        registration.setEnabled(true);
        registration.setOrder(Integer.MAX_VALUE - 1);
        registration.addUrlPatterns("/*");
        return registration;
    }

}


